using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Security;
using LoveMusic.Helpers;
using LoveMusic.Models;

namespace LoveMusic
{

    public class FacebookController : BaseController, IDisposable
    {
        #region private

        private readonly IDataContext _dataContext;
        private static readonly int _topTags = 50;

        private IDataContext DataContext
        {
            [System.Diagnostics.DebuggerStepThrough]
            get
            {
                return _dataContext;
            }
        }

        /// <summary>
        /// Initializes the <see cref="SongController"/> class.
        /// </summary>
        static FacebookController()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="SongController"/> class.
        /// </summary>
        /// <param name="dataContext">The data context.</param>
        /// <param name="userManager">The membership provider that will be used.</param>
        public FacebookController(IDataContext dataContext, MembershipProvider userManager)
            : base(userManager)
        {
            _dataContext = dataContext;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="SongController"/> class.
        /// </summary>
        public FacebookController()
            : this(new ModelDataContext(), Membership.Provider)
        {
        }

        #endregion

        /// <summary>
        /// Get the artist
        /// </summary>
        /// <param name="artistName">The artistName (Mandatory).</param>
        [CompressFilter]
        [OutputCache(Duration = int.MaxValue, VaryByParam = "none")]
        public ActionResult Index()
        {
            var viewData = GetViewData<StartDetailData>();
            return View("Index", viewData);
        }



        #region Utilities

        private T GetViewData<T>() where T : BaseViewData, new()
        {
            var viewData = new T
            {
                AllMoods = DataContext.AllMoods(),
                RandArtists = DataContext.Get50Artist(),
                RandSong = DataContext.Get50Songs()
            };

            return viewData;
        }

        #endregion
    }
}
